<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace api\home\controller;

use cmf\controller\RestBaseController;
use think\Db;
use think\Validate;
use EasyWeChat\Factory;
use think\Config;

class CommonController extends RestBaseController
{

    public $Token;
    public $UserId;
    public function __construct(){
        $token =  input('token') ? input('token') : $_SERVER['HTTP_TOKEN'];
        if(!$token){
            $this->error('请先登陆！');
        }
        $session = Db::table('a_user')->where(['session'=>$token])->value('session');
        if(!$session){
            echo json_encode(array('code'=>'90001','msg'=>'token已过期'));die;
            $this->error('token已过期!');
        }
        $this->Token = $token;
        $this->UserId = substr($this->Token,12);
    }

}